home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
tool+
/
TimeManager
< prev
next >
Wrap
Text File
|
1994-06-24
|
3KB
|
99 lines
\ Revised Time manager...used for any system >6.0.3 - assumes register A1
\ contains address of record at proc call
\ 5/18/93 rfl revised for new gestalt of version 3.64
\ 8/05/93 rfl changed init: to setProc:
\ 1/25/94 rfl fixed elapsed:
\ Read IMIV for a description of what this might be used for..care must
\ be taken not to move memory, rely on unlocked handles, etc.
\ Remember to remove tasks prior to exiting the application.
create Tinstall ( ptr -- result) popA0 " InsTime" asmcall pushd0 next,
create Tremove ( ptr -- result) popA0 " rmvTime" asmcall pushd0 next,
create Tprime ( len ptr -- result) popD0 popA0 " primeTime" asmcall pushd0 next,
:CLASS timeTask <super object
int microseconds \ true if delay in microseconds
var myProc \ myProc in relative address, will move on install
var tmDelay
var qlink \ setup extended record, even though this is revised class
int qtype
var tmAddr
var tmCount
:M setProc: ( 'cfaProc --) >body put: myProc ;M
:M microseconds: ( b --) put: microseconds ;M
\ once installed, and then removed, you may reInstall using this method
:M reInstall: ( --) get: myProc +base put: tmAddr
clear: qType clear: qLink clear: tmCount
abs: qlink Tinstall abort" can't install" ;M
\ Use this method as the first thing...It loads up the record with values
:M install: ( -- ) get: myProc body> initProc reInstall: self ;M
\ To remove the task from the queue
:M remove: ( --) abs: qlink Tremove abort" can't remove" ;M
\ positive value is milliseconds, negative value is microseconds
:M setDelay: ( n --) get: microseconds IF negate THEN put: tmDelay ;M
:M getDelay: ( -- n) get: tmDelay get: microseconds IF negate THEN ;M
\ start the task...it doesn't repeat, but must be restarted for continuous operation
:M go: abs: qlink get: tmDelay Tprime abort" can't start" ;M
:M start: go: self ;M
:M stop: remove: self ;M
\ return time remaining during countdown
\ :M time: ( -- microseconds) get: tmCount 20 * ;M
\ return time remaining after task has been stopped or executed
:M remaining: ( -- microseconds) get: tmCount
dup 0< IF negate ELSE 1000 * THEN ;M
\ return time elapsed after task has been stopped or executed
:M elapsed: ( -- microsecs )
get: tmDelay
get: microseconds not
IF 1000 * ELSE negate THEN
remaining: self - ;M
:M on: ( --b) 'type sysv (gestalt) 0= \ check if revised TM
IF $ 603 >=
IF get: qType $ 8000 and
IF true ELSE false THEN
ELSE ." not supported"
THEN
ELSE ." not supported"
THEN ;M
:M pause: stop: self ;M
\ continue counting after a pause...will count so that timer will run for original delay
:M resume: remaining: self get: microseconds not
IF 1000 / THEN setDelay: self reinstall: self go: self ;M
;CLASS
\ procedure is to install a TprocWord, set the delay when the TprocWord should execute,
\ and when you want to start timing, say go:
\ When you're completely done, just remove:
\ rect suz
\ 100 100 200 200 put: suz
\
\ timeTask painter
\ :proc paintit pushPort set: fwind paint: suz popPort ;proc
\ 5000 setdelay: painter
\
\ 'c paintit init: painter
\ install: painter
\ go: painter